Type = {}
require("Base/BTReq")

--节点类型实例化
function Type:GetType(name, text)
    -- 实现动态代码:
    -- local log=BTLog:new(...)
    --[[        local Name = "BT" .. name
            if type(text)=="string" then
                loadstring(Name..':New("'..text..'")')()
            end
            if type(text)=="number" then
                return loadstring(Name..":New"..text..")")()
            end]]

    --Action
    if name == "ActionUniversal" then
        return BTActionUniversal:New()
    end

    --Log
    if name == "Log" then
        return BTLog:New(text)
    end

    --Wait
    if name == "Wait" then
        --number还是string
        local time = tonumber(text)
        return BTWait:New(time)
    end

    --Parallel
    if name == "Parallel" then
        return BTParallel:New()
    end

    --Selector
    if name == "Selector" then
        return BTSelector:New()
    end

    --Sequence
    if name == "Sequence" then
        return BTSequence:New()
    end

    --Conditional
    if name == "Conditional" then
        return BTConditionalUniversal:New()
    end

    --IsAlive
    if name == "IsAlive" then
        local number=tonumber(text)
        return BTIsAlive:New(number)
    end

    --AlwaysFailure
    if name=="AlwaysFailure" then
        return BTAlwaysFailure:New()
    end

    --Inverter
    if name == "Inverter" then
        return BTInverter:New()
    end

    --Repeater
    if name == "Repeater" then
        local n = tonumber(text)
        return BTRepeater:New(n)
    end

    --UntilFailure
    if name == "UntilFailure" then
        return BTUntilFailure:New()
    end
end

